﻿/*****************************************************************************

   Project:   WP7AppLifecycleService
   File:      IApplicationStateHandler.cs 
   Creator:   David Carballo (dacarb@gmail.com)
   
   Description:
      Definition of IApplicationStateHandler interface.

   (C) Copyright 2011, David Carballo
       http://wp7applifecycle.codeplex.com/license

******************************************************************************/

namespace WP7AppLifecycleService
{
    /// <summary>
    /// Interface that needs to be implemented by classes
    /// responsible of saving the data of the application, the application state, when the
    /// application is tombstoned, and restoring such data when the app comes back to life
    /// after having been tombstoned.
    /// </summary>
    /// <remarks>It is very likely state will be saved using PhoneApplicationService.Current.State,
    /// but it is not mandatory (i.e. isolated storage could be used) provided the max of 10 
    /// seconds is met when saving ALL the application state.</remarks>
    public interface IApplicationStateHandler
    {
        /// <summary>
        /// Gets a value indicating whether there is application state saved.
        /// </summary>
        /// <value>A bool value indicating whether there is application state saved.</value>
        /// <remarks>Take into account the situation where the app was tombstoned
        /// before initialization was completed. If the stored data are not 
        /// fully complete return false.</remarks>
        bool IsThereApplicationStateSaved { get; }

        /// <summary>
        /// Saves the data of the application when the application is tombstoned.
        /// </summary>
        void SaveApplicationState();

        /// <summary>
        /// Restores the data of the application when the application comes back to life
        /// after having been tombstoned.
        /// </summary>
        void RestoreApplicationState();

        /// <summary>
        /// Deletes any state saved when the application was tombstoned. 
        /// <para>This method will automatically be called right after RestoreApplicationState is
        /// successfully executed.</para>
        /// </summary>
        void DeleteApplicationState();
    }
}
